# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=pyjfuzz
pkgver=159.578d44c
pkgrel=1
pkgdesc='Python JSON Fuzzer.'
groups=('blackarch' 'blackarch-fuzzer')
arch=('any')
url='https://github.com/mseclab/PyJFuzz'
license=('MIT')
depends=('python2' 'python2-bottle' 'python2-netifaces' 'python2-argparse'
         'python2-wsgiref' 'python2-pyopenssl' 'python2-gramfuzz'
         'python2-gitpython' 'python2-setuptools')
makedepends=('git' 'python2-setuptools')
source=("$pkgname::git+https://github.com/mseclab/PyJFuzz.git"
        'setup.py.patch')
sha512sums=('SKIP'
            '9836f1811d527845b29a25d05dac9fddff6dc1703c4e661f833228a4f81b2a1b316cf1bb17c7deaf02d3b86b76a76d498d25646a894ad95fa0120d41022914c7')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

prepare() {
  cd $pkgname

  patch -Np0 -i ../setup.py.patch
}

build() {
  cd $pkgname

  python2 setup.py build
}

package() {
  cd $pkgname

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  mv "$pkgdir/usr/bin/pjf" "$pkgdir/usr/bin/$pkgname"
}

